## Protocol Analysis: Baloo-Crystal

### **Protocol Type**
This is an implementation of **Crystal**, a low-power wireless protocol that uses **synchronous transmissions (Glossy flooding)** combined with **time-slotted communication**. Crystal is a **many-to-many (mp2mp) data collection protocol** designed for energy-efficient, reliable communication in wireless sensor networks.

### **Protocol Operation**
Crystal operates in rounds consisting of:
1. **Synchronization phase** using Glossy floods
2. **Time-slotted data collection phases** with transmission (T) and acknowledgment (A) slots (TA pairs)
3. **Adaptive termination** based on network activity (empty TA pairs)

The protocol uses **concurrent transmissions** (Glossy) where multiple nodes transmit simultaneously to achieve constructive interference, improving reliability and reducing latency.

---

## **Tunable Parameters Analysis**

### **1. tx_power (Transmission Power)**

**Current value:** 31 (maximum power level)

**Impact on Performance Metrics:**

- **PRR (Packet Reception Rate):**
  - ↑ Higher tx_power → ↑ Better PRR
  - Stronger signals overcome noise and interference
  - Extended communication range ensures more nodes participate in Glossy floods
  - **Trade-off:** Diminishing returns at very high power; may cause interference in dense networks

- **Energy Consumption:**
  - ↑ Higher tx_power → ↑ Higher energy consumption
  - Radio transmission is the dominant energy consumer
  - Crystal's synchronous transmission nature means ALL participating nodes transmit at high power
  - **Critical impact:** Energy scales non-linearly with power level

- **Latency:**
  - Minimal direct impact
  - Indirectly: Better PRR may reduce retransmissions, slightly lowering latency
  - Crystal's time-slotted structure dominates latency characteristics

**Optimization Hints:**
- Start with **moderate power levels (15-25)** to balance PRR and energy
- Use **adaptive power control**: reduce power when PRR is consistently high
- Consider **topology**: dense networks may perform well with lower power
- Monitor **link quality metrics** to find the minimum viable tx_power

---

### **2. n_tx_max (Maximum Glossy Retransmissions)**

**Current value:** 5

**Impact on Performance Metrics:**

- **PRR (Packet Reception Rate):**
  - ↑ Higher n_tx_max → ↑ Better PRR
  - More retransmissions increase probability of successful packet reception
  - Glossy's constructive interference benefits from multiple transmissions
  - **Saturation point:** Beyond a threshold, additional retransmissions yield minimal PRR improvement

- **Energy Consumption:**
  - ↑ Higher n_tx_max → ↑ Higher energy consumption
  - Each retransmission costs energy for ALL nodes in the flood
  - Linear relationship: doubling n_tx_max roughly doubles energy per flood
  - **Multiplier effect:** Energy cost = n_tx_max × (nodes participating) × (tx energy)

- **Latency:**
  - ↑ Higher n_tx_max → ↑ Higher latency
  - Each Glossy flood takes longer to complete
  - Affects both synchronization and data transmission phases
  - **Cumulative impact:** Longer rounds mean less frequent data collection opportunities

**Optimization Hints:**
- **Start with n_tx_max = 3-4** for typical multi-hop networks
- Use **adaptive n_tx_max**: 
  - Reduce when PRR is high (stable network)
  - Increase when PRR drops (challenging conditions)
- Consider **network diameter**: n_tx_max should be ≥ (network diameter + 1)
- Monitor **n_empty_ta**: if rounds terminate early, n_tx_max may be too high

---

## **Joint Optimization Strategy**

### **Energy-Optimal Configuration:**
- **tx_power:** 15-20 (medium-low)
- **n_tx_max:** 3-4
- **Rationale:** Minimize energy while maintaining acceptable PRR (>90%)
- **Best for:** Long-term deployments, battery-powered nodes

### **PRR-Optimal Configuration:**
- **tx_power:** 27-31 (high)
- **n_tx_max:** 5-7
- **Rationale:** Maximize reliability at the cost of energy
- **Best for:** Critical applications, short-term missions

### **Balanced Configuration:**
- **tx_power:** 22-25 (medium)
- **n_tx_max:** 4-5
- **Rationale:** Good PRR (>95%) with reasonable energy consumption
- **Best for:** General-purpose deployments

### **Adaptive Approach:**
1. **Start conservative:** tx_power=25, n_tx_max=4
2. **Monitor PRR:** If PRR < 90%, increase n_tx_max first (cheaper than tx_power)
3. **Monitor energy:** If duty cycle > target, reduce tx_power gradually
4. **Use n_empty_ta feedback:** Tune n_tx_max to match actual network activity

---

## **Key Insights**

1. **n_tx_max has broader impact** than tx_power because it affects timing, energy, and PRR simultaneously
2. **tx_power is more efficient** for improving PRR in sparse networks or long-range links
3. **Crystal's synchronous nature** amplifies energy costs—every node pays for every transmission
4. **The n_empty_ta parameter** (set to 2) provides early termination, partially mitigating high n_tx_max costs
5. **Network topology matters:** Dense networks tolerate lower tx_power; sparse networks need higher n_tx_max